﻿using System;
using System.Data;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseData;
using BaseData.UI;
using TaxBiz.SysConfig;
using TaxEntity.SysConfig;

namespace Admin.SysConfig
{
    public partial class XiangzhenModify : BaseCommon.BasePage
    {
        protected string id = string.Empty;
        protected XiangzhenEntity de = new XiangzhenEntity();
        protected XiangzhenBiz db = new XiangzhenBiz();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HasPower())
            {
                Jscript.AlertAndGoBack("您权限不足，不能操作");
                return;
            }
            id = PageContext.GetRequest("id");
            if (string.IsNullOrEmpty(id))
            {
                Jscript.AlertAndGoBack("参数错误");
                return;
            }
            int iId = 0;
            int.TryParse(id, out iId);
            if (iId <= 0)
            {
                Jscript.AlertAndGoBack("参数错误");
                return;
            }
            de = db.GetEntityById(iId);
            if (de == null)
            {
                Jscript.AlertAndGoBack("参数错误");
                return;
            }

            string action = PageContext.GetRequest("action");
            if (!string.IsNullOrEmpty(action))
            {
                this.DoAction(action, iId);
            }
        }

        protected bool DoAction(string action, int id)
        {
            XiangzhenEntity de = new XiangzhenEntity();
            de.ID = id;
            de.OptUserID = UserLogin.UserId;
            de.Code = PageContext.GetRequest("txtCode");
            de.Name = PageContext.GetRequest("txtName");
            bool isSucc = db.Update(de, UserLogin);
            if (!isSucc)
            {
                Jscript.Alert("修改失败");
                return false;
            }

            Jscript.AlertAndRedirect("修改成功", "XiangzhenModify.aspx?id=" + id);
            return true;
        }
    }
}